#ifndef THREADPOOL_H
#define THREADPOOL_H

#include <QObject>
#include <QThread>
#include <QQueue>
#include <QMutex>
#include <QWaitCondition>
#include <QRunnable>
#include <QThreadPool>

class ThreadPoolWorker : public QThread {
    Q_OBJECT
public:
    ThreadPoolWorker(QObject *parent = nullptr);
protected:
    void run() override;
};

class ThreadPool : public QObject {
    Q_OBJECT
public:
    explicit ThreadPool(int maxThreads = QThread::idealThreadCount(), QObject *parent = nullptr);
    ~ThreadPool();

    void start(QRunnable *runnable);
    void setMaxThreadCount(int maxThreads);
    int activeThreadCount() const;
    int maxThreadCount() const;

private:
    QThreadPool *m_pool;
};

#endif // THREADPOOL_H
